package daily.may0527;

import java.util.stream.Stream;

public class StreamFilterTest {
    public static void main(String[] args) {
        String[] stringsArray = new String[]{"张三", "张三丰", "赵敏", "周芷若", "张无忌"};
        Stream<String> stringsStream = Stream.of(stringsArray);
        //筛选姓张的，三个字的
        stringsStream.filter(name -> name.startsWith("张"))
                .filter(name -> 3 == name.length())
                .forEach(s -> System.out.print(s + " "));//张三丰 张无忌
        //上述操作也可以通过逻辑运算符&&完成
//        stringsStream.filter(name -> name.startsWith("张") && 3 == name.length())
//                .forEach(s -> System.out.print(s + " "));//张三丰 张无忌
    }
}
